package com.punch.common.feign.fallback;

import com.punch.common.dto.login.AppLoginUserDTO;
import com.punch.common.feign.FeignPlatformUserService;
import com.punch.common.model.LoginUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FeignPlatformUserServiceFallbackFactory implements FallbackFactory<FeignPlatformUserService> {

    @Override
    public FeignPlatformUserService create(Throwable throwable) {
        return new FeignPlatformUserService() {
            @Override
            public LoginUser getUserByMobile(String mobile) {
                log.error("根据手机号码获取app用户登录信息异常:{}", mobile, throwable);
                return new LoginUser();
            }

            @Override
            public void saveOrUpdatePlatformUser(AppLoginUserDTO appLoginUserDTO) {
                log.error("保存/更新app用户信息异常:{}", appLoginUserDTO, throwable);
            }

            /**
             * 平台用户忘记密码
             *
             * @param appLoginUserDTO 平台用户表单
             */
            @Override
            public Boolean forgetUserPwd(AppLoginUserDTO appLoginUserDTO) {
                log.error("平台用户忘记密码异常:{}", appLoginUserDTO, throwable);
                return false;
            }
        };
    }
}
